<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ERP登录</title>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>/style/themes/bootstrap/easyui.css" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>/style/icon.css" />
    <link rel=" stylesheet" type="text/css" href="<%=basePath%>/style/index.css" />
    <script>
        if (window.location.href.indexOf("<%=basePath%>/system/user/login") == -1) {
        	debugger
            window.location='<%=basePath%>/system/user/login';
        }
    </script>
    <style>
        .panel {
            margin: 200px auto;
        }

        #loginForm tr {
            height: 30px;
            line-height: 30px;
        }

        .icon-lock {
            background-size: auto 76%;
        }
    </style>
</head>
<body style=" background-size: 100%">
    <div class="easyui-panel" title="Darryring ERP V2.0" style="width:400px" data-options="closable:true,collapsible:true">
        <div style="padding:10px 30px 20px 30px">
            <form id="loginForm" class="easyui-form" method="post" action="" data-options="novalidate:true">
                <table cellpadding="5">
                    <tr>
                        <td>用户名：</td>
                        <td><input class="easyui-textbox" type="text" id="name" data-options="required:true,iconCls:'icon-man'"></input></td>
                        <td rowspan="3" style="padding-left: 20px">
                            <img src="<%=basePath%>/img/erplogo.png" style="width:90px;height: 90px" />
                        </td>
                    </tr>
                    <tr>
                        <td>密&nbsp; &nbsp; 码：</td>
                        <td><input class="easyui-textbox" type="password" id="pwd" data-options="required:true,iconCls:'icon-lock'"></input></td>
                    </tr>
                    <tr>
                        <td>
                            验证码：
                        </td>
                        <td>
                            <input class="easyui-textbox" type="text" id="code" data-options="required:true" style="width: 90px"></input>
                            <img id="valiCode" style="cursor: pointer;" src='<%=basePath%>/system/user/getValidateCode")' alt="点击刷新验证码" />
                        </td>
                    </tr>
                </table>
            </form>
            <div style="text-align:center;padding:5px">
                <a href="javascript:void(0)" style="width: 100%" class="easyui-linkbutton" onclick="submitForm()">登 &nbsp;录</a>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="<%=basePath%>/Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/Scripts/jquery.easyui.min.js"></script>
    <script src="<%=basePath%>/Scripts/jquery.edatagrid.js"></script>
    <script src="<%=basePath%>/Scripts/easyui-lang-zh_CN.js"></script>
    <script src="<%=basePath%>/Plugins/jgxLoader.js"></script>
    <script src="<%=basePath%>/Scripts/md5.js"></script>
    <script>
        $(function () {
            $.get('/<%=basePath%>/System/User/GetBingImage', function (data) {
                $('body').css('background-image', 'url(' + data + ')');
            });
            $("#valiCode").bind("click", function () {
                var url = '<%=basePath%>/system/user/getValidateCode' + "?time=" + (new Date()).getTime();
                $("#valiCode").attr("src", url);
            });
            document.onkeydown = function (e) {

                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    submitForm();
                }
            };
        });
        function submitForm() {
            begainLoad();
            $.post("<%=basePath%>/system/user/loginin", { name: $('#name').val(), pwd: MD5($('#pwd').val()), code: $('#code').val() }, function (data) {
                if (data == "") { 
                    window.location.href = "<%=basePath%>/home?id=3";
                } else {
                    endLoad();
                    $.messager.alert("提示", data);
                }
            });
        }

        function clearForm() {
            $('#loginForm').form('clear');
        }
        
    </script>
</body>
</html>